//
//  TVCouponViewModel.swift
//  iPhone
//
//  Created by Toj on 12/1/22.
//

import UIKit

class TVCouponViewModel: NSObject {
    private(set) var tips = ""
    
    var recentlyCouponModel: TVCouponCellModel? { didSet {
        guard let _ = recentlyCouponModel else {
            return
        }
        selectedCouponModel = nil
        tips = recentlyCouponModel?.discountTips ?? ""
    } }
    
    var selectedCouponModel: TVCouponCellModel? { willSet {
        selectedCouponModel?.isSelected = false
        newValue?.isSelected = true
    } didSet {
        guard let _ = selectedCouponModel else {
            guard recentlyCouponModel == nil else { return }
            tips = "membership_CouponListTip1".localized()
            return
        }
        recentlyCouponModel = nil
        tips = selectedCouponModel?.tips ?? ""
    } }
    
    private(set) var cellModels: [TVCouponCellModel] = []
    init(models: [TVCouponCellModel]) {
        cellModels = models
    }
}
